<template>
  <div class="contentmenu-wrapper" :style="`left:${pos.x}px;top:${pos.y}px`">
    <div class="item" v-for="(item, index) in data" :key="'item' + index" @click="itemClick(item)">{{ item.label }}</div>
  </div>
</template>

<script>
export default {
  name: 'contextmenu',
  props: {
    data: {
      type: Array,
      default: () => [
        {
          label: '评论',
          key: 1
        },
        {
          label: '复制',
          key: 1
        },
        {
          label: '举报',
          key: 1
        },
        {
          label: '开启评论',
          key: 1
        },
        {
          label: '删除消息',
          key: 1
        }
      ]
    },
    pos: {
      type: Object,
      default: () => {
        return {
          x: 0,
          y: 0
        }
      }
    }
  },
  methods: {
    itemClick(item) {
      this.$emit('menuClick', item)
    }
  }
}
</script>

<style>
.contentmenu-wrapper {
  position: absolute;
  top: 100px;
  left: 100px;
  z-index: 100;
  width: 120px;
  background: #ffffff;
  border: 1px solid;
  border-color: #e9eef7;
  border-radius: 4px;
  box-shadow: 0px 2px 12px rgba(0, 0, 0, 0.1);
  padding: 4px 1px;
}

.contentmenu-wrapper .item {
  width: 118px;
  height: 32px;
  font-family: Microsoft YaHei;
  color: #1f1f1f;
  font-size: 14px;
  line-height: 32px;
  padding-left: 16px;
  text-align: left;
  box-sizing: border-box;
  cursor: pointer;
}
.contentmenu-wrapper .item:hover {
  background: #f0f5ff;
}
</style>
